<?php if(!defined('HOST'))die('not access');//caozuo?>
<script >
$(document).ready(function(){
	{params};
	var modenum = 'cgtype',modename='采购分类',isflow=1,modeid='4',atype = params.atype,pnum=params.pnum,modenames='';
	if(!atype)atype='';
	var a = $('#veiw_{rand}').bootstable({
		tablename:'cgtype',celleditor:true,sort:'id',dir:'desc',modedir:'{mode}:{dir}',params:{},checked:true,fanye:true,
		columns:[
			{
				text:'ID',dataIndex:'id',sortable:true
			},{
				text:'名称',dataIndex:'name',sortable:true
			},{
				text:'类型',dataIndex:'type',sortable:true
			},{
				text:'父ID',dataIndex:'pid'
			},{
				text:'操作',dataIndex:'caozuo',callback:'opegs{rand}'
			}],
		rendertr:function(d){
			var s = '';
			if(d.level==2)s='style="color:red"';
			return s;
		}
	});
	

	var c = {
		delss:function(){
			a.del({url:js.getajaxurl('del','{mode}','{dir}'),checked:true});
		},
		clickwin:function(o1,lx){
			var id=0;
			if(lx==1)id=a.changeid;
			openinput(modename,modenum,id,'opegs{rand}');
		},
		search:function(){

			a.setparams({},true);
		},
		searchbtn:function(){
			this.search({});
		},
		init:function(){
			$('#key_{rand}').keyup(function(e){
				if(e.keyCode==13)c.searchbtn();
			});
			this.initpage();
		},
		initpage:function(){
			
		},
		loaddata:function(d){
			this.setdownsodata(d.souarr);
			if(!d.atypearr)return;
			get('addbtn_{rand}').disabled=(d.isadd!=true);
			get('daobtn_{rand}').disabled=(d.isdaochu!=true);
			if(d.isdaochu)$('#daobtn_{rand}').show();
			if(d.isdaoru)$('#daoruspan_{rand}').show();
			var d1 = d.atypearr,len=d1.length,i,str='';
			for(i=0;i<len;i++){
				str+='<button class="btn btn-default" click="changatype,'+d1[i].num+'" id="changatype{rand}_'+d1[i].num+'" type="button">'+d1[i].name+'</button>';
			}
			$('#changatype{rand}').html(str);
			$('#changatype{rand}_'+atype+'').addClass('active');
			js.initbtn(c);
		},
		storeurl:function(){
			var url = this.getacturl('publicstore')+'&pnum='+pnum+'';
			return url;
		},
		getacturl:function(act){
			return js.getajaxurl(act,'mode_work|input','flow',{'modeid':modeid});
		}
	};

	js.initbtn(c);

	c.init();
});
//getshtml
</script>


<div>


<table width="100%"><tr>
	<td style="padding-right:10px;" id="tdleft_{rand}" nowrap>
		<button id="addbtn_{rand}" class="btn btn-primary" click="clickwin,0" type="button"><i class="icon-plus"></i> 新增</button>
	</td>
	<td nowrap style="padding-left:10px">
		<!-- 
		<button class="btn btn-default" click="search" type="button">搜索</button>&nbsp; 
		 -->
	</td>
	

</tr>
</table>
</div>
<div class="blank10"></div>
<div id="veiw_{rand}"></div>